import request from '@/utils/request'

export const crawlerTaskApi = {
    // 获取所有任务
    getTasks() {
        return request.get('/ctrip/crawler-tasks')
    },
    // 创建任务
    createTask(data) {
        return request.post('/ctrip/crawler-tasks', data)
    },
    // 更新任务
    updateTask(id, data) {
        return request.put(`/ctrip/crawler-tasks/${id}`, data)
    },
    // 删除任务
    deleteTask(id) {
        return request.delete(`/ctrip/crawler-tasks/${id}`)
    },
    // 暂停任务
    pauseTask(id) {
        return request.post(`/ctrip/crawler-tasks/${id}/pause`)
    },
    // 恢复任务
    resumeTask(id) {
        return request.post(`/ctrip/crawler-tasks/${id}/resume`)
    },
    // 立即执行任务
    executeTask(id) {
        return request.post(`/ctrip/crawler-tasks/${id}/execute`)
    },
    // 获取任务日志
    getTaskLogs(id, limit = 50) {
        return request.get(`/ctrip/crawler-tasks/${id}/logs`, { limit } )
    }
}